import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:star_author/config/base_configuration.dart';
import 'package:star_author/widgets/custom_button/go_back_button.dart';

class CustomAppBar extends AppBar {
  CustomAppBar(
    Widget title, {
    Key? key,
    Widget? leading,
    List<Widget>? actions,
    Widget? flexibleSpace,
    PreferredSizeWidget? bottom,
    Color? shadowColor,
    ShapeBorder? shape,
    Color backgroundColor = Colors.white,
    SystemUiOverlayStyle? systemOverlayStyle,
    IconThemeData iconTheme = const IconThemeData(
      color: Colors.black,
    ),
    IconThemeData? actionsIconTheme,
    TextStyle toolbarTextStyle = const TextStyle(
      color: ColorConf.normal,
      fontSize: 14,
    ),
    TextStyle titleTextStyle = const TextStyle(
      color: ColorConf.normal,
      fontSize: 18,
    ),
    double? toolbarHeight,
    double? leadingWidth,
    bool primary = true,
    bool excludeHeaderSemantics = false,
    bool automaticallyImplyLeading = true,
    double? titleSpacing,
    double? actionsRight,
  }) : super(
          key: key,
          leading: automaticallyImplyLeading
              ? GoBackButton(
                  color: iconTheme.color ?? Colors.black,
                )
              : leading,
          automaticallyImplyLeading: automaticallyImplyLeading,
          title: title,
          actions: [
            Container(
              alignment: Alignment.center,
              padding: EdgeInsets.only(right: actionsRight ?? 12.w),
              child: Row(
                children: actions ?? [],
              ),
            ),
          ],
          flexibleSpace: flexibleSpace,
          bottom: bottom,
          elevation: 1.w,
          shadowColor: shadowColor ?? Colors.black.withOpacity(0.2),
          shape: shape,
          backgroundColor: backgroundColor,
          systemOverlayStyle: systemOverlayStyle,
          iconTheme: iconTheme,
          actionsIconTheme: actionsIconTheme,
          toolbarTextStyle: toolbarTextStyle,
          titleTextStyle: titleTextStyle,
          primary: primary,
          centerTitle: true,
          excludeHeaderSemantics: excludeHeaderSemantics,
          titleSpacing: titleSpacing ?? 15.w,
          toolbarOpacity: 1.0,
          bottomOpacity: 1.0,
        );
}
